<template>
  <div id="payment_success">
    <loading text="订单处理中"></loading>
    <alert :title="COMPANY_GAME_NAME"></alert>
  </div>
</template>

<script>
import { Loading, Alert } from "vux";
export default {
  data() {
    return {};
  },
  created() {
    //显示订单处理中
    this.showLoading();
    let query = this.$route.query;
    let getsearchorder = query => {
      this.apiService.payment.searchorder(query).then(res => {
        if (res.code == 0 && res.data != 0) {
          clearInterval(timer);
          this.$router.push({
            path: `/payment/result`,
            query: query
          });
        } else if (res.code == 2) {
          clearInterval(timer);
          this.showLoading();
          this.$vux.alert.show({
            content: res.msg
          });
        }
      });
    };
    let timer = setInterval(function() {
      getsearchorder(query);
    }, 1000);
  },
  components: {
    Loading,
    Alert
  },
  methods: {
    showLoading() {
      this.$vux.loading.show();
      setTimeout(() => {
        this.$vux.loading.hide();
      }, 100);
    }
  }
};
</script>
<style scoped>
#payment_success {
  padding: 0.2rem;
}
</style>

